//package com.spice.im;
//
//
//import java.io.File;
//
//
//
//
//
//
//import java.util.HashMap;
//import java.util.Map;
//import java.util.Properties;
//import java.util.concurrent.ExecutorService;
//import java.util.concurrent.Executors;
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//import org.jivesoftware.smack.packet.IQ;
//import org.jivesoftware.smack.packet.Packet;
//import org.jivesoftware.smack.util.StringUtils;
//
//
//
//
//
//
//
//
//
//
//
//
//
////import com.allen.ui.profile.FormatTools;
////import com.example.android.bitmapfun.util.AsyncTask;
////import com.speed.im.utils.AsyncTask;
////import com.speed.im.utils.AsyncTask.Status;
//import com.lxb.uploadwithprogress.http.HttpMultipartPost;
//import com.speed.im.login.EncryptionUtil;
////import com.speed.im.RegisterStep.onNextActionListener;
//import com.spice.im.RegisterStep.onNextActionListener;
//import com.spice.im.friend.SearchIQ;
//import com.spice.im.friend.SearchIQResponse;
//import com.spice.im.friend.SearchIQResponseProvider;
//import com.spice.im.register.IsRegisteredIQ;
//import com.spice.im.register.IsRegisteredIQResponse;
//import com.spice.im.register.IsRegisteredIQResponseProvider;
//import com.spice.im.register.RegisterIQ;
//import com.spice.im.register.RegisterIQResponse;
//import com.spice.im.register.RegisterIQResponseProvider;
//import com.spice.im.utils.AsyncTask;
//import com.spice.im.utils.HeaderLayout;
//import com.spice.im.utils.PhotoUtils;
//import com.spice.im.utils.HeaderLayout.HeaderStyle;
//import com.stb.isharemessage.BeemApplication;
//import com.stb.isharemessage.service.aidl.IXmppConnection;
//import com.stb.isharemessage.service.aidl.IXmppFacade;
//import com.stb.isharemessage.utils.FileUtils;
////import com.stb.isharemessage.utils.HeaderLayout;
////import com.stb.isharemessage.utils.PhotoUtils;
//////import com.stb.isharemessage.utils.PhotoUtils;
////import com.stb.isharemessage.utils.HeaderLayout.HeaderStyle;
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//import android.app.AlertDialog;
//import android.content.ComponentName;
//import android.content.Context;
//import android.content.DialogInterface;
//import android.content.Intent;
//import android.content.ServiceConnection;
//import android.content.SharedPreferences;
//import android.database.Cursor;
//import android.graphics.Bitmap;
//import android.graphics.BitmapFactory;
//import android.net.Uri;
////import android.os.AsyncTask;
//import android.os.Bundle;
//import android.os.Handler;
//import android.os.IBinder;
//import android.os.RemoteException;
//import android.preference.PreferenceManager;
//import android.provider.MediaStore;
////import android.support.v4.app.FragmentActivity;
//import android.util.Log;
//import android.view.View;
//import android.view.Window;
//import android.view.View.OnClickListener;
//import android.widget.Button;
//import android.widget.TextView;
//import android.widget.Toast;
//import android.widget.ViewFlipper;
//
//public class BakRegisterActivity extends BaseActivity implements OnClickListener,onNextActionListener{
////    /**
////     * 静态加载ReconnectionManager，重连才能正常工作*/
////    static{   
////	    try{  
////	       Class.forName("org.jivesoftware.smack.ReconnectionManager");  
////	    }catch(Exception e){  
////	        e.printStackTrace();  
////	    }  
////    }
//	private HeaderLayout mHeaderLayout;
//	private ViewFlipper mVfFlipper;
//	private Button mBtnPrevious;
//	private Button mBtnNext;
//	
//	private Button mBtnSkip;
//
//	private BaseDialog mBackDialog;
//	private RegisterStep mCurrentStep;
//	private StepPhone mStepPhone;
//	private StepVerify mStepVerify;
//	public  String verification = "";
//	private StepSetPassword mStepSetPassword;
//	private StepBaseInfo mStepBaseInfo;
//	private StepBirthday mStepBirthday;
//	private StepPhoto mStepPhoto;
//	
//	public String username = "";
//	public String password = "";
//	public String avatorpath = "";
////	public byte[] avatorbytes = null;
// 	public Map<String, String> attributes = new HashMap<String, String>();
//
//	private int mCurrentStepIndex = 1;
//	
//    public String uploadHost;
//    public String picuploadHost;
//    public String downloadPrefix;
//    
//    private final static float TARGET_HEAP_UTILIZATION = 0.75f;
//    private final static int CWJ_HEAP_SIZE = 6* 1024* 1024 ;
//    private static final Intent SERVICE_INTENT = new Intent();
//	static {
//		//pkg,cls
////		SERVICE_INTENT.setComponent(new ComponentName("com.test", "com.stb.isharemessage.BeemService"));
////		SERVICE_INTENT.setComponent(new ComponentName("com.stb.isharemessage", "com.stb.isharemessage.BeemService"));
//		SERVICE_INTENT.setComponent(new ComponentName("com.spice.im", "com.stb.isharemessage.BeemService"));//自身应用pkg名称，非service所在pkg名称
//	}
//	private final ServiceConnection mServConn = new BeemServiceConnection();
//    private boolean mBinded = false;
//    private IXmppFacade mXmppFacade;
//    private IXmppConnection mConnection;
//    protected Context mContext;
//	@Override
//	protected void onCreate(Bundle savedInstanceState) {
//		requestWindowFeature(Window.FEATURE_NO_TITLE);
//		super.onCreate(savedInstanceState);
//		setContentView(R.layout.activity_register);
//		mContext = this;
//		mSettings = PreferenceManager.getDefaultSharedPreferences(this);
//		
//        Properties props = new Properties();
//        try {
//            int id = this.getResources().getIdentifier("androidpn", "raw",
//            		this.getPackageName());
//            props.load(this.getResources().openRawResource(id));
//        } catch (Exception e) {
////            Log.e(LOGTAG, "Could not find the properties file.", e);
//            // e.printStackTrace();
//        }
//        uploadHost = props.getProperty("uploadHost", "");
//        picuploadHost = props.getProperty("picuploadHost", "");
//        downloadPrefix = props.getProperty("downloadPrefix", "");
//		
//		initViews();
//		mCurrentStep = initStep();
//		initEvents();
//		initBackDialog();
//		
//		
//		errorMsg2.put("0001","0001 已登陆，不能注册");
//		errorMsg2.put("0002","0002 用户名非法（为空或这长度不是3-15位）");
//		errorMsg2.put("0003","0003 用户名包含非法字符");
//		errorMsg2.put("0004","0004 用户名已被注册");
//		errorMsg2.put("0006","0006 未开放注册");
//		errorMsg2.put("0007","0007 未开放邀请注册");
//		errorMsg2.put("0008","0008 密码非法（为空或包含转意符）");
//		errorMsg2.put("0008","0009 两次输入密码不一致");
//		errorMsg2.put("0010","0010 email邮箱格式不对");
//		errorMsg2.put("0011","0011 email邮箱已被注册");
//		errorMsg2.put("0012","0012 同意个ip不允许一小时内同时注册多个用户");
//		errorMsg2.put("9998","9998 注册失败");
//		errorMsg2.put("0000","0000|newUid 注册成功，返回uid");
//		errorMsg2.put("9999","9999 注册失败");
//		errorMsg2.put("9997","9997 服务连接中1-1,请稍候再试.");
//	}
//    @Override
//    protected void onStart() {
//    	super.onStart();
//        if (!mBinded)
//    	    mBinded = bindService(BakRegisterActivity.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
////    	IntentFilter filter = new IntentFilter(MemorizingTrustManager.INTERCEPT_DECISION_INTENT
////    		+ "/" + getPackageName());
////    	filter.setPriority(RECEIVER_PRIORITY);
////    	registerReceiver(mSslReceiver, filter);
//    }
//    
//    @Override
//    protected void onStop() {
//		super.onStop();
//		if (mBinded) {
//		    unbindService(mServConn);
//		    mXmppFacade = null;
//		    mBinded = false;
//		}
////		unregisterReceiver(mSslReceiver);
//    }
//	@Override
//	protected void onDestroy() {
//		PhotoUtils.deleteImageFile(this);
//		mBackDialog.dismiss();
//		super.onDestroy();
//	}
//	@Override
//	protected void initViews() {
//		mHeaderLayout = (HeaderLayout) findViewById(R.id.reg_header);
//		mHeaderLayout.init(HeaderStyle.TITLE_RIGHT_TEXT);
//		mVfFlipper = (ViewFlipper) findViewById(R.id.reg_vf_viewflipper);
//		mVfFlipper.setDisplayedChild(0);
//		mBtnPrevious = (Button) findViewById(R.id.reg_btn_previous);
//		mBtnNext = (Button) findViewById(R.id.reg_btn_next);
//		mBtnSkip = (Button) findViewById(R.id.reg_btn_skip);
//	}
//
//	@Override
//	protected void initEvents() {
//		mCurrentStep.setOnNextActionListener(this);
//		mBtnPrevious.setOnClickListener(this);
//		mBtnNext.setOnClickListener(this);
//		mBtnSkip.setOnClickListener(this);
//	}
//	@Override
//	public void onBackPressed() {
//		if (mCurrentStepIndex <= 1) {
//			if(mCurrentStepIndex == 1)
//			mBackDialog.show();
//		} else {
//			doPrevious();
//		}
//	}
//
//	@Override
//	public void onClick(View arg0) {
//		switch (arg0.getId()) {
//		case R.id.reg_btn_previous:
//			if (mCurrentStepIndex <= 1) {//<=1
//				if(mCurrentStepIndex == 1)
//				mBackDialog.show();
//			} else {
//				doPrevious();
//			}
//			break;
//
//		case R.id.reg_btn_next:
//			if (mCurrentStepIndex < 6) {
//				doNext();
//			} else {
//				if (mCurrentStep.validate()) {
//					mCurrentStep.doNext();
//				}
//			}
//			break;
//		case R.id.reg_btn_skip:
//			if(mCurrentStepIndex < 6 && mCurrentStepIndex==4){//跳过后续步骤直接注册账号密码
////				mBtnSkip.setVisibility(View.GONE);
//				doStraightRegister();
//			}else {
////				mBtnSkip.setVisibility(View.VISIBLE);
//				mCurrentStep.doNext();
//			}
//		}
//	}
//
//	@SuppressWarnings("deprecation")
//	@Override
//	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//		super.onActivityResult(requestCode, resultCode, data);
//		switch (requestCode) {
//		case PhotoUtils.INTENT_REQUEST_CODE_ALBUM:
//			if (data == null) {
//				return;
//			}
//			if (resultCode == RESULT_OK) {
//				if (data.getData() == null) {
//					return;
//				}
//				if (!FileUtils.isSdcardExist()) {
//					showCustomToast("SD卡不可用,请检查");
//					return;
//				}
//				Uri uri = data.getData();
//				String[] proj = { MediaStore.Images.Media.DATA };
//				Cursor cursor = managedQuery(uri, proj, null, null, null);
//				if (cursor != null) {
//					int column_index = cursor
//							.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
//					if (cursor.getCount() > 0 && cursor.moveToFirst()) {
//						String path = cursor.getString(column_index);
//						Bitmap bitmap = BitmapFactory.decodeFile(path);
//						if (PhotoUtils.bitmapIsLarge(bitmap)) {
//							PhotoUtils.cropPhoto(this, this, path);
//						} else {
//							mStepPhoto.setUserPhoto(bitmap);
//							if(bitmap!=null){
//								sendOfflineFile(path,"img");
////								iconpath = path;
//								avatorpath = path;
////								avatorbytes = FormatTools.getInstance().Bitmap2Bytes(bitmap);
//							}
//						}
//					}
//				}
//			}
//			break;
//
//		case PhotoUtils.INTENT_REQUEST_CODE_CAMERA:
//			if (resultCode == RESULT_OK) {
//				String path = mStepPhoto.getTakePicturePath();
//				Bitmap bitmap = BitmapFactory.decodeFile(path);
//				if (PhotoUtils.bitmapIsLarge(bitmap)) {
//					PhotoUtils.cropPhoto(this, this, path);
//				} else {
//					mStepPhoto.setUserPhoto(bitmap);
//					if(bitmap!=null){
//						sendOfflineFile(path,"img");
////						iconpath = path;
//						avatorpath = path;
////						avatorbytes = FormatTools.getInstance().Bitmap2Bytes(bitmap);
//					}
//				}
//			}
//			break;
//
//		case PhotoUtils.INTENT_REQUEST_CODE_CROP:
//			if (resultCode == RESULT_OK) {
//				String path = data.getStringExtra("path");
//				if (path != null) {
//					Bitmap bitmap = BitmapFactory.decodeFile(path);
//					if (bitmap != null) {
//						mStepPhoto.setUserPhoto(bitmap);
//						if(bitmap!=null){
//							sendOfflineFile(path,"img");
////							iconpath = path;
//							avatorpath = path;
////							avatorbytes = FormatTools.getInstance().Bitmap2Bytes(bitmap);
//						}
//					}
//				}
//			}
//			break;
//		}
//	}
//
//	@Override
//	public void next() {
//		mCurrentStepIndex++;
//		mCurrentStep = initStep();
//		mCurrentStep.setOnNextActionListener(this);
//		mVfFlipper.setInAnimation(this, R.anim.push_left_in);
//		mVfFlipper.setOutAnimation(this, R.anim.push_left_out);
//		mVfFlipper.showNext();
//	}
//
//	private RegisterStep initStep() {
//		if(mCurrentStepIndex < 6 && mCurrentStepIndex!=4){
//			mBtnSkip.setVisibility(View.GONE);
//		}else {
//			mBtnSkip.setVisibility(View.VISIBLE);
//		}
//		
//		switch (mCurrentStepIndex) {
//		case 1:
//			if (mStepPhone == null) {
//				mStepPhone = new StepPhone(this, mVfFlipper.getChildAt(0));
//			}
//			mHeaderLayout.setTitleRightText("注册新账号", null, "1/6");
//			mBtnPrevious.setText("返    回");
//			mBtnNext.setText("下一步");
//			return mStepPhone;
//
//		case 2:
//			if (mStepVerify == null) {
//				mStepVerify = new StepVerify(this, mVfFlipper.getChildAt(1));
//			}
//			mHeaderLayout.setTitleRightText("填写验证码", null, "2/6");
//			mBtnPrevious.setText("上一步");
//			mBtnNext.setText("下一步");
//			return mStepVerify;
//
//		case 3:
//			if (mStepSetPassword == null) {
//				mStepSetPassword = new StepSetPassword(this,
//						mVfFlipper.getChildAt(2));
//			}
//			mHeaderLayout.setTitleRightText("设置密码", null, "3/6");
//			mBtnPrevious.setText("上一步");
//			mBtnNext.setText("下一步");
//			return mStepSetPassword;
//
//		case 4:
//			if (mStepBaseInfo == null) {
//				mStepBaseInfo = new StepBaseInfo(this, mVfFlipper.getChildAt(3));
//			}
//			mHeaderLayout.setTitleRightText("填写基本资料", null, "4/6");
//			mBtnPrevious.setText("上一步");
//			mBtnSkip.setText("跳过直接注册");
//			mBtnNext.setText("下一步");
//			return mStepBaseInfo;
//
//		case 5:
//			if (mStepBirthday == null) {
//				mStepBirthday = new StepBirthday(this, mVfFlipper.getChildAt(4));
//			}
//			mHeaderLayout.setTitleRightText("您的生日", null, "5/6");
//			mBtnPrevious.setText("上一步");
//			mBtnNext.setText("下一步");
//			return mStepBirthday;
//
//		case 6:
//			if (mStepPhoto == null) {
//				mStepPhoto = new StepPhoto(this, mVfFlipper.getChildAt(5));
//			}
//			mHeaderLayout.setTitleRightText("设置头像", null, "6/6");
//			mBtnPrevious.setText("上一步");
//			mBtnSkip.setText("跳过直接注册");
//			mBtnNext.setText("注    册");
//			return mStepPhoto;
//		}
//		return null;
//	}
//
//	private void doPrevious() {
//		mCurrentStepIndex--;
//		mCurrentStep = initStep();
//		mCurrentStep.setOnNextActionListener(this);
//		mVfFlipper.setInAnimation(this, R.anim.push_right_in);
//		mVfFlipper.setOutAnimation(this, R.anim.push_right_out);
//		mVfFlipper.showPrevious();
//	}
//
//	private void doNext() {
//		if (mCurrentStep.validate()) {
//			if (mCurrentStep.isChange()) {
//				mCurrentStep.doNext();
//			} else {
//				next();
//			}
//		}
//	}
//
//	private void initBackDialog() {
//		mBackDialog = BaseDialog.getDialog(BakRegisterActivity.this, "提示",
//				"确认要放弃注册么?", "确认", new DialogInterface.OnClickListener() {
//
//					@Override
//					public void onClick(DialogInterface dialog, int which) {
//						dialog.dismiss();
//						finish();
//					}
//				}, "取消", new DialogInterface.OnClickListener() {
//
//					@Override
//					public void onClick(DialogInterface dialog, int which) {
//						dialog.cancel();
//					}
//				});
//		mBackDialog.setButton1Background(R.drawable.btn_default_popsubmit);
//
//	}
//	@Override
//	protected void putAsyncTask(AsyncTask<Void, Void, Boolean> asyncTask) {
//		super.putAsyncTask(asyncTask);
//	}
//
//	@Override
//	protected void showCustomToast(String text) {
//		super.showCustomToast(text);
//	}
//
//	@Override
//	protected void showLoadingDialog(String text) {
//		super.showLoadingDialog(text);
//	}
//
//	@Override
//	protected void dismissLoadingDialog() {
//		super.dismissLoadingDialog();
//	}
//
//	protected int getScreenWidth() {
//		return mScreenWidth;
//	}
//	protected String getPhoneNumber() {
//		if (mStepPhone != null) {
//			return mStepPhone.getPhoneNumber();
//		}
//		return "";
//	}
//	
//	
//	public SharedPreferences mSettings;
//    private static final boolean DEFAULT_BOOLEAN_VALUE = false;
//	private static final String DEFAULT_STRING_VALUE = "";
//	private static final int DEFAULT_XMPP_PORT = 5222;
//	public static final int NOTIFICATION_DURATION = Toast.LENGTH_SHORT;
//    public int isRegister(String username) {
//    	int int_isregister = 2;//0 未注册可以注册,1已注册,2注册状态未知（通讯错误）
//	    try {
//	    	mConnection = mXmppFacade.createConnection();
//		    if (!mConnection.connect()) {
//		    	Log.d("######@@@@@@******RegisterActivity result000******@@@@@@######", "result000");
//		    	BeemApplication.getInstance().setConnected(false);
//	    		int_isregister = 2;
//		    }else{
//		    	Log.d("######@@@@@@******RegisterActivity result111******@@@@@@######", "result111");
//	    	if(mXmppFacade!=null){
//	    		Log.d("######@@@@@@******RegisterActivity result333******@@@@@@######", "result333");
//		    	if (mXmppFacade.getXmppConnectionAdapter()!=null 
//						&& mXmppFacade.getXmppConnectionAdapter().getAdaptee()!=null
//						&& mXmppFacade.getXmppConnectionAdapter().getAdaptee().isConnected() 
//						&& mXmppFacade.getXmppConnectionAdapter().login()//注意，第三方登陆login之前，需要调用框架本身的auth接口
////		    			&& mXmppFacade.getXmppConnectionAdapter().getAdaptee().isAuthenticated() //登录成功后才会startService，因此登录时不要判断isAuthenticated及isAlive
////		    			&& mXmppFacade.getXmppConnectionAdapter().getAdaptee().isAlive()
//		    			){
//		    		Log.d("######@@@@@@******RegisterActivity result444******@@@@@@######", "result444");
//		    		IsRegisteredIQ reqXML = new IsRegisteredIQ();
//		            reqXML.setId("1234567890");
//		            reqXML.setApikey("abcdefghijklmnopqrstuvwxyz");
//		            reqXML.setUsername(username);
//		            String uuid = mXmppFacade.getXmppConnectionAdapter().getAdaptee().getUUID(this);
//		            reqXML.setUuid(uuid);
////		            String hashcode = "";//apikey+uuid+username 使用登录成功后返回的sessionid作为密码做3des运算
//		            String hash_dest_src = "abcdefghijklmnopqrstuvwxyz"+uuid+username;
//		            String hash_dest = EncryptionUtil.getHash2(hash_dest_src, "SHA");
//		            reqXML.setHashcode(hash_dest);
//		            reqXML.setType(IQ.Type.SET);
//		            String elementName = "isregisterediq"; 
//		    		String namespace = "com:isharemessage:isregisterediq";
//		    		IsRegisteredIQResponseProvider provider = new IsRegisteredIQResponseProvider();
//		            Packet rt =  mXmppFacade.getXmppConnectionAdapter().excute(reqXML, "isregisterediq", "com:isharemessage:isregisterediq", provider);
//		            
//		            if(rt!=null){
//		                if (rt instanceof IsRegisteredIQResponse) {
//		                	final IsRegisteredIQResponse isRegisteredIQResponse = (IsRegisteredIQResponse) rt;
//
//		                    if (isRegisteredIQResponse.getChildElementXML().contains(
//		                            "com:isharemessage:isregisterediq")) {
//		    					BakRegisterActivity.this.runOnUiThread(new Runnable() {
//			                    	
//        							@Override
//        							public void run() {
//        								showCustomToast("服务器应答消息："+isRegisteredIQResponse.toXML().toString());
//        							}
//        						});
//		                        String Id = isRegisteredIQResponse.getId();
//		                        String Apikey = isRegisteredIQResponse.getApikey();
//		                        String retcode = isRegisteredIQResponse.getRetcode();
//		                        //0001 用户名不允许为空
//		                        //0002 查询用户失败,hash校验失败
//		                        //0003 用户名包含非法字符
//		                        //0004 此用户名已被注册
//		                        //0005 此用户名不允许注册
//		                        //9997 查询用户失败
//		                        String memo = isRegisteredIQResponse.getMemo();
//		                        String isregister = isRegisteredIQResponse.getIsregister();//是否已注册 : 0 未注册 1 已注册额
//		                        
//		                        verification = isRegisteredIQResponse.getVerification();//验证码
//		                        
//		                        if(retcode.equals("0000")){
//		                        	int_isregister = 0;
////		                        	verification
//		                        }else if(retcode.equals("0001"))
//		                        	int_isregister = 3;
//		                        else if(retcode.equals("0002"))
//		                        	int_isregister = 4;
//		                        else if(retcode.equals("0003"))
//		                        	int_isregister = 5;
//		                        else if(retcode.equals("0004"))
//		                        	int_isregister = 6;
//		                        else if(retcode.equals("0005"))
//		                        	int_isregister = 7;
//		                        else if(retcode.equals("9997"))
//		                        	int_isregister = 8;
//		                        
//		                        
//		                    }else
//		                    	int_isregister = 2;
//		                } 
//		            }else
//		            	int_isregister = 2;
//		    	}else{
//		    		Log.d("######@@@@@@******RegisterActivity result555******@@@@@@######", "result555");
//		    		BeemApplication.getInstance().setConnected(false);
//		    		int_isregister = 2;
//		    	}
//	    	}else{
//	    		Log.d("######@@@@@@******RegisterActivity result222******@@@@@@######", "result222");
//	    		BeemApplication.getInstance().setConnected(false);
//	    		int_isregister = 2;
//	    	}
//		    }
//	    } catch (RemoteException e) {
//	    	e.printStackTrace();
//	    	BeemApplication.getInstance().setConnected(false);
//	    	int_isregister = 2;
//	    	
//	    } catch (Exception e){
//	    	e.printStackTrace();
//	    	BeemApplication.getInstance().setConnected(false);
//	    	int_isregister = 2;
//	    }
//    	return int_isregister;
//    }
//    
//    public String errorMsg = null;
//    
//	public HashMap errorMsg2 = new HashMap();
////	String[]{"0001 已登陆，不能注册",
////				    		"0002 用户名非法（为空或这长度不是3-15位）",
////				    		"0003 用户名包含非法字符",
////				    		"0004 用户名已被注册",
////				    		"0006 未开放注册",
////				    		"0007 未开放邀请注册",
////				    		"0008 密码非法（为空或包含转意符）",
////				    		"0009 两次输入密码不一致",
////				    		"0010 email邮箱格式不对",
////				    		"0011 email邮箱已被注册",
////				    		"0012 同意个ip不允许一小时内同时注册多个用户",
////				    		"9998 注册失败",
////				    		"0000|newUid 注册成功，返回uid",
////				    		"9999 注册失败",
////				    		"9997 服务连接中1-1,请稍候再试."};
//	public String errorType = "9999";
//	
//    /**
//     * Create an account on the XMPP server specified in settings.
//     * @param username the username of the account.
//     * @param password the password of the account.
//     * @return true if the account was created successfully.
//     */
//    public String createAccount(String username, String password,Map<String, String> attributes) {
//    	try{
//	    	if(mXmppFacade!=null){
//	    		Log.d("######@@@@@@******RegisterActivity result333******@@@@@@######", "result333");
//		    	if (mXmppFacade.getXmppConnectionAdapter()!=null 
//						&& mXmppFacade.getXmppConnectionAdapter().getAdaptee()!=null
//						&& mXmppFacade.getXmppConnectionAdapter().getAdaptee().isConnected() 
//						&& mXmppFacade.getXmppConnectionAdapter().login()//注意，第三方登陆login之前，需要调用框架本身的auth接口
//	//	    			&& mXmppFacade.getXmppConnectionAdapter().getAdaptee().isAuthenticated() //登录成功后才会startService，因此登录时不要判断isAuthenticated及isAlive
//	//	    			&& mXmppFacade.getXmppConnectionAdapter().getAdaptee().isAlive()
//		    			){
//		    		Log.d("######@@@@@@******RegisterActivity result444******@@@@@@######", "result444");
//		    		RegisterIQ reqXML = new RegisterIQ();
//		            reqXML.setId("1234567890");
//		            reqXML.setApikey("abcdefghijklmnopqrstuvwxyz");
////		            reqXML.setUid("--");
//		            reqXML.setUsername(username);
//		            reqXML.setPassword(password);
//		            reqXML.setPassword2(password);
//		            reqXML.setEmail(attributes.get("email"));
//		            String uuid = mXmppFacade.getXmppConnectionAdapter().getAdaptee().getUUID(this);
//		            reqXML.setUuid(uuid);
//		            
//	//	            String hashcode = "";//apikey+uuid+username 使用登录成功后返回的sessionid作为密码做3des运算
//		            String hash_dest_src = "abcdefghijklmnopqrstuvwxyz"+uuid;
//		            String hash_dest = EncryptionUtil.getHash2(hash_dest_src, "SHA");
//		            reqXML.setHashcode(hash_dest);
//		            reqXML.setType(IQ.Type.SET);
//		            String elementName = "registeriq"; 
//		    		String namespace = "com:isharemessage:registeriq";
//		    		RegisterIQResponseProvider provider = new RegisterIQResponseProvider();
//		            Packet rt =  mXmppFacade.getXmppConnectionAdapter().excute(reqXML, "registeriq", "com:isharemessage:registeriq", provider);
//		            
//		            if(rt!=null){
//		                if (rt instanceof RegisterIQResponse) {
//		                	final RegisterIQResponse registerIQResponse = (RegisterIQResponse) rt;
//	
//		                    if (registerIQResponse.getChildElementXML().contains(
//		                            "com:isharemessage:registeriq")) {
//		    					BakRegisterActivity.this.runOnUiThread(new Runnable() {
//			                    	
//	    							@Override
//	    							public void run() {
//	    								showCustomToast("服务器应答消息："+registerIQResponse.toXML().toString());
//	    							}
//	    						});
//		                        String Id = registerIQResponse.getId();
//		                        String Apikey = registerIQResponse.getApikey();
//		                        String retcode = registerIQResponse.getRetcode();
//		                        //0001 已登陆，不能注册
//					    		//0002 用户名非法（为空或这长度不是3-15位）
//					    		//0003 用户名包含非法字符
//					    		//0004 用户名已被注册
//					    		//0006 未开放注册
//					    		//0007 未开放邀请注册
//					    		//0008 密码非法（为空或包含转意符）
//					    		//0009 两次输入密码不一致
//					    		//0010 email邮箱格式不对
//					    		//0011 email邮箱已被注册
//					    		//0012 同意个ip不允许一小时内同时注册多个用户
//					    		//9998 注册失败
//					    		//0000|newUid 注册成功，返回uid
//					    		//9999 注册失败
//		                        String memo = registerIQResponse.getMemo();
//		                        String uid = registerIQResponse.getUid();//是否已注册 : 0 未注册 1 已注册额
//		                        
//		                        
//		                        if(retcode.startsWith("0000"))
//		                        	errorType = "0000";
//		                        else
//		                        errorType = retcode;
//		                        
//		                        
//		                    }else
//		                    	errorType = "9997";
//		                } 
//		            }else
//		            	errorType = "9997";
//		    	}else{
//		    		Log.d("######@@@@@@******RegisterActivity result555******@@@@@@######", "result555");
//		    		BeemApplication.getInstance().setConnected(false);
//		    		errorType = "9997";
//		    	}
//	    	}else{
//	    		Log.d("######@@@@@@******RegisterActivity result222******@@@@@@######", "result222");
//	    		BeemApplication.getInstance().setConnected(false);
//	    		errorType = "9997";
//	    	}
//    	}catch(RemoteException e){
//    		e.printStackTrace();
//    		errorType = "9997";
//    	}catch(Exception e){
//    		e.printStackTrace();
//    		errorType = "9997";
//    	}
//		return errorType;
//    }
//    
//    
//    
//    /**
//     * Retrieve proxy use from the preferences.
//     * @return Registered proxy use
//     */
//    private boolean getRegisteredProxyUse() {
//    	return mSettings.getBoolean(BeemApplication.PROXY_USE_KEY, DEFAULT_BOOLEAN_VALUE);
//    }
//    /**
//     * Retrieve proxy username from the preferences.
//     * @return Registered proxy username
//     */
//    private String getRegisteredProxyUsername() {
//    	return mSettings.getString(BeemApplication.PROXY_USERNAME_KEY, DEFAULT_STRING_VALUE);
//    }
//    /**
//     * Retrieve proxy password from the preferences.
//     * @return Registered proxy password
//     */
//    private String getRegisteredProxyPassword() {
//    	return mSettings.getString(BeemApplication.PROXY_PASSWORD_KEY, DEFAULT_STRING_VALUE);
//    }
//    /**
//     * Retrieve proxy port from the preferences.
//     * @return Registered proxy port
//     */
//    private int getRegisteredProxyPort() {
//    	return Integer.parseInt(mSettings.getString(BeemApplication.PROXY_PORT_KEY, DEFAULT_STRING_VALUE));
//    }
//    /**
//     * Retrieve proxy server from the preferences.
//     * @return Registered proxy server
//     */
//    private String getRegisteredProxyServer() {
//    	return mSettings.getString(BeemApplication.PROXY_SERVER_KEY, DEFAULT_STRING_VALUE);
//    }
//    /**
//     * Retrieve xmpp port from the preferences.
//     * @return Registered xmpp port
//     */
//    private int getXMPPPort() {
//		int port = DEFAULT_XMPP_PORT;
//		if (mSettings.getBoolean("settings_key_specific_server", false))
//		    port = Integer.parseInt(mSettings.getString("settings_key_xmpp_port", "5222"));
//		return port;
//    }
//
//    /**
//     * Retrieve xmpp server from the preferences.
//     * @return Registered xmpp server
//     */
//    private String getXMPPServer() {
////		TextView xmppServerTextView = (TextView) findViewById(R.id.create_account_username);
//		String xmppServer = "124.127.117.238";//10.0.2.2
//		if (mSettings.getBoolean("settings_key_specific_server", false))
//		    xmppServer = mSettings.getString("settings_key_xmpp_server", "124.127.117.238").trim();//10.0.2.2
//		//注释掉:从用户名中的@resource中解析服务器地址
//	//	else
//	//	    xmppServer = StringUtils.parseServer(xmppServerTextView.getText().toString());
//		return xmppServer;
//    }
//    /**
//     * Retrieve TLS use from the preferences.
//     * @return Registered TLS use
//     */
//    private boolean getRegisteredXMPPTLSUse() {
//    	return mSettings.getBoolean("settings_key_xmpp_tls_use", DEFAULT_BOOLEAN_VALUE);
//    }
//    /**
//     * Create a dialog containing an error message.
//     * @param errMsg the error message
//     */
//    private void createErrorDialog(String errMsg) {
//		AlertDialog.Builder builder = new AlertDialog.Builder(this);
//		builder.setTitle(R.string.create_account_err_dialog_title)
//		    .setMessage(errMsg)
//		    .setCancelable(false)
//		    .setIcon(android.R.drawable.ic_dialog_alert);
//		builder.setNeutralButton(R.string.create_account_close_dialog_button, new DialogInterface.OnClickListener() {
//	
//		    @Override
//		    public void onClick(DialogInterface dialog, int which) {
//			dialog.cancel();
//		    }
//		});
//		AlertDialog settingsErrDialog = builder.create();
//		settingsErrDialog.show();
//    }
//    
//    private HttpMultipartPost post;
//    private static ExecutorService LIMITED_TASK_EXECUTOR;  
//      
//    static {    
//        LIMITED_TASK_EXECUTOR = (ExecutorService) Executors.newFixedThreadPool(7);
//    }; 
//    private void sendOfflineFile(String filepath,String type) {
//			try{
//				post = new HttpMultipartPost(handler);
////				post.execute(filepath,xmppConnectionAdapter.getAdaptee().getUser(),mContact.getJIDWithRes());
////				Params[] params;
//				handler.sendEmptyMessage(2);
//				post.executeOnExecutor(LIMITED_TASK_EXECUTOR,
//						filepath,
//						username,
//						username,
//						type,
//						"",
//						picuploadHost);
////						"http://10.0.2.2:9090/plugins/picfiletransfer/picfiletransfer"); 
//			}catch(Exception e){
//				Log.e("error", "RejectedExecutionException in content_img: " +  filepath+";"+e.getMessage());
//			}
//		
//	}
//	private Handler handler = new Handler() {
//		
//		public void handleMessage(android.os.Message msg) {
//			switch (msg.what) {
//			case 2:
////				if(pb.getVisibility()==View.GONE){
////					pb.setMax(100);
////					pb.setProgress(0);
////					pb.setVisibility(View.VISIBLE);
////				}
//				showLoadingDialog("请稍后,正在设置...0%");
//				break;
//			case 3:
////				pb.setProgress(msg.arg1);
//				showLoadingDialog("请稍后,正在设置..."+msg.arg1*100/msg.arg2+"%");
//				break;
//			case 4:
////				pb.setVisibility(View.GONE);
////				upload = false;
//				dismissLoadingDialog();
////				attributes.put("avatorpath", avatorpath);
//				if(avatorpath!=null && avatorpath.length()!=0 && !avatorpath.equalsIgnoreCase("null"))
//				attributes.put("email", avatorpath.substring(avatorpath.lastIndexOf(File.separator)+1));
//				break;
//			default:
//				break;
//			}
//		}
//	};
//	
//	
//    /**
//     * The service connection used to connect to the Beem service.
//     */
//    private class BeemServiceConnection implements ServiceConnection {
//		/**
//		 * Constructor.
//		 */
//		public BeemServiceConnection() {
//		}
//	
//		@Override
//		public void onServiceConnected(ComponentName name, IBinder service) {
//		    mXmppFacade = IXmppFacade.Stub.asInterface(service);
//		    if(mXmppFacade!=null){
//		    	mBinded = true;
//		    }
//		}
//		@Override
//		public void onServiceDisconnected(ComponentName name) {
//		    mXmppFacade = null;
//		    mBinded = false;
//		}
//    }
//    
//    
//	public void doStraightRegister() {
//		putAsyncTask(new AsyncTask<Void, Void, Boolean>() {
//
//			@Override
//			protected void onPreExecute() {
//				super.onPreExecute();
//				showLoadingDialog("请稍后,正在提交...");
//			}
//
//			@Override
//			protected Boolean doInBackground(Void... params) {
//				try {
//					Thread.sleep(2000);
////					return (mActivity.createAccount(mActivity.username, mActivity.password, mActivity.attributes));
//					if((createAccount(username, password, attributes)).startsWith("0000"))
//						return true;
////							&& mActivity.saveUserVCard(mActivity.avatorbytes, mActivity.username+"@pc2011040521xsg"));
////					return true;
//				} catch (InterruptedException e) {
//
//				}
//				return false;
//			}
//
//			@Override
//			protected void onPostExecute(Boolean result) {
//				super.onPostExecute(result);
//				dismissLoadingDialog();
//				if (result) {
//				    Toast toast = Toast.makeText(BakRegisterActivity.this, String.format(
//				    		getString(R.string.create_account_successfull_after), username), NOTIFICATION_DURATION);
//				    	    toast.show();
//				    	    
//				    		SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(BakRegisterActivity.this);
//				    		SharedPreferences.Editor edit = settings.edit();
////				    		edit.putString(BeemApplication.ACCOUNT_USERNAME_KEY, mActivity.username+"@pc2011040521xsg");
//				    		edit.putString(BeemApplication.ACCOUNT_USERNAME_KEY, username);
//				    		edit.putString(BeemApplication.ACCOUNT_PASSWORD_KEY, password);
//				    		edit.commit();
//					
//					Intent i = new Intent(BakRegisterActivity.this, Login.class);
//				    i.putExtra("isConfig", 1);//0 false 1 true
//				    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//				    BakRegisterActivity.this.startActivity(i);
//				    
//				    BakRegisterActivity.this.finish();
//				}else{
//					Toast toast = Toast.makeText(BakRegisterActivity.this, (String)errorMsg2.get(errorType), NOTIFICATION_DURATION);
//				    	    toast.show();
//				    BakRegisterActivity.this.finish();
//				}
//			}
//
//		});
//	}
//}
